#include<iostream>
#include<cstdio>
using namespace std;
int n;
struct node{
	int v;
	int nxt,lst;
};
node a[200005];
bool vis[200005];
int main(){
	freopen("fruit.in","r",stdin);
	freopen("fruit.out","w",stdout);
	scanf("%d",&n);
	for(int i=1;i<=n;i++){
		scanf("%d",&a[i].v);
		a[i].lst=i-1;
		a[i].nxt=i+1;
	}
	a[n+1].nxt=-1;
	int sum=0;
	while(true){
		int i=1;
		while(vis[i]==true){
			i++;
		}
		while(a[i].nxt!=-1){
			int tt=i;
			printf("%d ",i);
			vis[i]=true;
			sum++;
			int x=i;
			while(a[x].v==a[i].v){
				x=a[x].nxt;
				if(x==(n+1)){
					break;
				}
			}
			i=x;
			a[a[tt].lst].nxt=a[tt].nxt;
			a[a[tt].nxt].lst=a[tt].lst;
		}
		if(sum==n){
			break;
		}
		printf("\n");
	}
	return 0;
}
